<include file='public/_meta'>

<div class="page-container">
	<div class="Huialert Huialert-success"><i class="Hui-iconfont">&#xe6a6;</i>
		<p class="c-primary">
		 	操作提示
		</p>
		<p>修改有效时长</p>
	</div>
	<form action="{:url('edit')}" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-type-add">
		<input type="hidden" name="id" value="{$data.id}">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				车牌号码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" id="search_text" name="car_sn" value="{$data.cars_info.car_sn}" class="input-text">
			</div>
		</div>
		<div class="row cl mb-30">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				选择有效时长(分钟):</label>
			<div class="formControls col-xs-6 col-sm-6">
				<span class="select-box" style="width:150px;">
                    <select class="select" name="minute" size="1">
	                   <option value="">请选择</option>
	                   <option value="10">10</option>
	                   <option value="15">15</option>
	                   <option value="20">20</option>
	                   <option value="25">25</option>
	                   <option value="30">30</option>
	                   <option value="60">60</option>
                	</select> 
                </span> <span class="c-primary ml-20">

				</span>
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-2">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;确认提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>

<!--_footer 作为公共模版分离出去-->
<include file='public/_footer'>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript">
$(function(){

	$("#form-type-add").validate({
		rules:{
			car_sn:{
				required:true,
			}	
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				dataType: 'json',
				success: function(data) { 
				 	var index = parent.layer.getFrameIndex(window.name);
	                if(data['code']==1){
	                
	                	layer.msg(data['msg'], {icon:6,time:1000},function(){

							parent.location.href = '{:url('index/custom/index')}';              		
	                	});
	                }else{
	                	layer.msg(data['msg']);
	                }
	                if(data['status'] ==1){
	                	layer.msg(data['msg']);
	                }
            	},
            	error:function(data){
					layer.msg('网络错误');
            	},


			});

		}
	});
});
$(function(){
    var url = "{:url('index/Record/ajaxGetCarSn')}";
    // var searchURL = "/cases/search.action";
    var isClicked = false;
    var defauntkeyword = "请输入关键词";
    $("#search_text").autocomplete(url, {
        scroll:false,
        selectFirst:false,
        delay:5,
        max:10,
        dataType:"json",//ajax的跨域，必须用jsonp,jQuery自动会加一个callback参数,后台要获得callback参数，并写回来
            //自定义提示
        tips:function(data) {
                //这里的data是跟formatItem 的data是一样的，所以格式也一样
            return data.pinyin;
        },
        parse: function(data) {
            if(data==null||typeof(data)=="undefined"||data.length==0){
                return null;
            }
            // console.log(data);

            // data = data.keylist;
            var rows = [];
            for(var i=0; i<data.length; i++){
                rows[rows.length] = {
                    data:data[i],//这里data是对象数组，格式[{key:aa,address:nn},{key:aa,address:nn}]
                    value:data[i].car_sn,
                    result:data[i].car_sn
                };
            } console.log(rows);
            return rows;
        },
        extraParams: {query:function (){return $('#search_text').val();}},
        formatItem: function(data, i, total) {  //就是下拉框显示的内容，可以有格式之类的
            return "<p class=''>"+data.car_sn+"</p>";
        },
        formatMatch: function(data, i, total) {  //要匹配的内容
            return data.car_sn;
        },
        formatResult: function(data) {  //最终在inputText里显示的内容，就是以后要搜索的内容
            return data.car_sn;
        }
    }).result(function(e, data) {
        if(!isClicked) {
            // startSearch();
        }
        if(data.car_id){
            $("#search_text").attr("value",data.car_id);
        }
    });

});

</script> 
<!--/请在上方写此页面业务相关的脚本-->